<? //include/ORDER_DETAILS_session.php

include("ORDER_DETAILS.php");

require_once'../include/database.php';
$conn = new Connection();
$conn->NewConnection('localhost','ecommerce','root','batavia');
class SessionORDER_DETAILS { 


 
 function find($id){
    
   global $conn;
   
   $query = "select OrderDetailID,OrderID,ProductID,Price,Quantity,Discount,Total,Size,Color,Fullfilled,BillDate,ShipDate,ShipperID,Freight,SalesTax from ORDER_DETAILS where OrderDetailID='$id'";
   
   $run = mysql_query($query) or die(mysql_error());
   
   $row = mysql_fetch_array($run, MYSQL_ASSOC);
   
   $numRow = mysql_numrows($run);
   
   if($numRow)
   
   {
   
   $this->ORDER_DETAILS= new ORDER_DETAILS();


   
	$this->ORDER_DETAILS->setOrderDetailID($row['OrderDetailID']);

 
	$this->ORDER_DETAILS->setOrderID($row['OrderID']);

 
	$this->ORDER_DETAILS->setProductID($row['ProductID']);

 
	$this->ORDER_DETAILS->setPrice($row['Price']);

 
	$this->ORDER_DETAILS->setQuantity($row['Quantity']);

 
	$this->ORDER_DETAILS->setDiscount($row['Discount']);

 
	$this->ORDER_DETAILS->setTotal($row['Total']);

 
	$this->ORDER_DETAILS->setSize($row['Size']);

 
	$this->ORDER_DETAILS->setColor($row['Color']);

 
	$this->ORDER_DETAILS->setFullfilled($row['Fullfilled']);

 
	$this->ORDER_DETAILS->setBillDate($row['BillDate']);

 
	$this->ORDER_DETAILS->setShipDate($row['ShipDate']);

 
	$this->ORDER_DETAILS->setShipperID($row['ShipperID']);

 
	$this->ORDER_DETAILS->setFreight($row['Freight']);

 
	$this->ORDER_DETAILS->setSalesTax($row['SalesTax']);

 
}
return $this->ORDER_DETAILS;
}

function insert($ORDER_DETAILS){
	global $conn;
	$query = "insert into ORDER_DETAILS(OrderDetailID,OrderID,ProductID,Price,Quantity,Discount,Total,Size,Color,Fullfilled,BillDate,ShipDate,ShipperID,Freight,SalesTax) values('".$ORDER_DETAILS->getOrderDetailID()."','".$ORDER_DETAILS->getOrderID()."','".$ORDER_DETAILS->getProductID()."','".$ORDER_DETAILS->getPrice()."','".$ORDER_DETAILS->getQuantity()."','".$ORDER_DETAILS->getDiscount()."','".$ORDER_DETAILS->getTotal()."','".$ORDER_DETAILS->getSize()."','".$ORDER_DETAILS->getColor()."','".$ORDER_DETAILS->getFullfilled()."','".$ORDER_DETAILS->getBillDate()."','".$ORDER_DETAILS->getShipDate()."','".$ORDER_DETAILS->getShipperID()."','".$ORDER_DETAILS->getFreight()."','".$ORDER_DETAILS->getSalesTax()."')";
 
 $parse=mysql_query($query);

 }
 
 function findall(){
	$query = "select OrderDetailID,OrderID,ProductID,Price,Quantity,Discount,Total,Size,Color,Fullfilled,BillDate,ShipDate,ShipperID,Freight,SalesTax from ORDER_DETAILS";
	$parse=mysql_query($query);
	$datas = array();
	while($row=mysql_fetch_assoc($parse))
	{
		$data = array();$data['OrderDetailID'] = $row['OrderDetailID'];
		$data['OrderID'] = $row['OrderID'];
		$data['ProductID'] = $row['ProductID'];
		$data['Price'] = $row['Price'];
		$data['Quantity'] = $row['Quantity'];
		$data['Discount'] = $row['Discount'];
		$data['Total'] = $row['Total'];
		$data['Size'] = $row['Size'];
		$data['Color'] = $row['Color'];
		$data['Fullfilled'] = $row['Fullfilled'];
		$data['BillDate'] = $row['BillDate'];
		$data['ShipDate'] = $row['ShipDate'];
		$data['ShipperID'] = $row['ShipperID'];
		$data['Freight'] = $row['Freight'];
		$data['SalesTax'] = $row['SalesTax'];
		$datas[] = $data;
	 }
	return $datas;
	}
	function delete($ORDER_DETAILS){
	$query = "delete from ORDER_DETAILS where OrderDetailID= '".$ORDER_DETAILS->getOrderDetailID()."'";
	$parse=mysql_query($query);
	return $parse;

	}
	
	function update($ORDER_DETAILS){
	$query = "update ORDER_DETAILS set OrderID= '".$ORDER_DETAILS->getOrderID()."',ProductID= '".$ORDER_DETAILS->getProductID()."',Price= '".$ORDER_DETAILS->getPrice()."',Quantity= '".$ORDER_DETAILS->getQuantity()."',Discount= '".$ORDER_DETAILS->getDiscount()."',Total= '".$ORDER_DETAILS->getTotal()."',Size= '".$ORDER_DETAILS->getSize()."',Color= '".$ORDER_DETAILS->getColor()."',Fullfilled= '".$ORDER_DETAILS->getFullfilled()."',BillDate= '".$ORDER_DETAILS->getBillDate()."',ShipDate= '".$ORDER_DETAILS->getShipDate()."',ShipperID= '".$ORDER_DETAILS->getShipperID()."',Freight= '".$ORDER_DETAILS->getFreight()."',SalesTax= '".$ORDER_DETAILS->getSalesTax()."' where OrderDetailID= '".$ORDER_DETAILS->getOrderDetailID()."'";
$parse=mysql_query($query);

}


}
 //include/ORDER_DETAILS_session.php